﻿using MediatR;
using S.PurchaseAndSales.Api.Application.Command.PurchaseFormCommand;
using S.PurchaseAndSales.Infrastructure.Interface.PurchaseForm;

namespace S.PurchaseAndSales.Api.Application.CommandHandlers.PurchaseFormHandler
{
    /// <summary>
    /// 仓库审核
    /// </summary>
    public class PurchaseFormRoundUpCommandHandler : IRequestHandler<PurchaseFormRoundUpCommand, bool>
    {
        #region 注入
        private readonly IPurchaseFormRepository repository;

        public PurchaseFormRoundUpCommandHandler(IPurchaseFormRepository repository)
        {
            this.repository = repository;
        }

        #endregion
        public async Task<bool> Handle(PurchaseFormRoundUpCommand request, CancellationToken cancellationToken)
        {
            //要审核数据的id
            int[] ids = request.PurchaseFormIds.Split(',').Select(int.Parse).ToArray();
            return  await repository.RoundUpPurchaseForm(ids, request.UpdateBy);
        }
    }
}
